// index.js

require('dotenv').config();
const express = require('express');
const app = express();
const methodOverride = require('method-override');

// 设置模板引擎为 EJS
app.set('view engine', 'ejs');
app.set('views', './app/views');


// 使用 method-override 中间件
app.use(methodOverride('_method'));

// 中间件
app.use(express.urlencoded({ extended: true }));
app.use(express.static('public'));

// 引入路由
const userRoutes = require('./app/routes/userRoutes');
app.use('/users', userRoutes);

// 启动服务器
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});